
Ext.define('desarrollo.FaseForm', {
    extend: 'Ext.form.Panel',
    alias: 'widget.fasesform',
    requires: ['Ext.form.field.Text'],
    initComponent: function(){		
        Ext.apply(this, {
            activeRecord: null,
            iconCls: 'icon-fase',
            frame: true,
            defaultType: 'textfield',
            bodyPadding: 20,
            fieldDefaults: {
                anchor: '100%',
            },
            items: [{
                fieldLabel: 'Id',
                name: 'id',
                type: 'int',
                itemId: 'idFase',
                hidden: true,
            },{
                fieldLabel: 'IdProy',
                name: 'idProyectoFase',
                type: 'int',
                itemId: 'idProy',
                hidden: true,
            },{
                fieldLabel: '<b>Nombre</b>',
                name: 'nombreFase',
                fieldStyle: 'background-color: transparent; border: none; background-image: none;',
                itemId: 'nombre',
            }, {
                fieldLabel: '<b>Descripcion</b>',
                name: 'descripcion',
                fieldStyle: 'background-color: transparent; border: none; background-image: none;',
                itemId: 'descripcion',
            }],
            dockedItems: [{
				xtype: 'toolbar',
				items: [
						{
						iconCls: 'icon-item',
						itemId: 'item',
						//disabled: true,
						text: '<b>Items</b>',
						hidden: true,
						scope: this, 
						handler: this.onItem
					},{}]
				},{
				weight: 1,
                xtype: 'toolbar',
                dock: 'bottom',
                items: ['->',{
                    iconCls: 'icon-reset',
                    text: '<b>Reset</b>',
                    scope: this,
                    handler: this.onReset
                }]
            }]
        });
        this.callParent();
    },

    setActiveRecord: function(record){
        this.activeRecord = record;
        if (record) {


			//if (!this.down('#item').isDisabled()){
				this.down('#item').show();			
			//}
            this.down('#nombre').setFieldStyle('background-color: transparent; border: none;');
			this.down('#descripcion').setFieldStyle('background-color: transparent; border: none;');
            this.getForm().loadRecord(record);
        } else {

            this.down('#item').hide();
            this.down('#nombre').setFieldStyle('background-color: transparent; border: none;');
			this.down('#descripcion').setFieldStyle('background-color: transparent; border: none;');
            
            //this.getForm().reset();
            this.down('#nombre').setValue("");
            this.down('#descripcion').setValue("");
            this.down('#idFase').setValue("");
            
        }
    },
    


	onItem: function(){
			var form = this.getForm();
			this.fireEvent('ddItem', form.getValues(true));            
	}, 	    

    onReset: function(){
        this.setActiveRecord(null);
        //this.getForm().reset();
        this.fireEvent('refresh');
    },

    
});
